include(['PClass'], 

function(){
	
	declare('materials.Material');
	Material = PClass.create({
		name        : '',
		strokeStyle : 'black',
		fillStyle   : 'black',
		lineWidth   : 0.5,
		fill        : false,
		stroke      : true,
		init   : function(name){
			this.name = name || 'Material ' + (Material.count++);
		},
		render : function(gw, obj){
			var c = gw.c;
			c.strokeStyle = this.strokeStyle;
			c.fillStyle = this.fillStyle;
			c.lineWidth = this.lineWidth;
			obj.render(gw);
			if(this.fill)   c.fill();
			if(this.stroke) c.stroke();
		}
	});
	Material.count = 1;
	Material.create = function(name, stroke, strokeStyle, lineWidth, fillStyle, fill){
		var result = new Material();
		if( arguments.length > 1 ){
			result.name = name || result.name;
			result.strokeStyle = strokeStyle || result.strokeStyle;
			result.stroke = stroke || result.stroke;
			result.lineWidth = lineWidth || result.lineWidth;
			result.fillStyle = fillStyle || result.fillStyle;
			result.fill = fill || result.fill;
		}else{
			var obj = name;
			result.name = obj.name || result.name;
			result.strokeStyle = obj.strokeStyle || result.strokeStyle;
			result.stroke = obj.stroke || result.stroke;
			result.lineWidth = obj.lineWidth || result.lineWidth;
			result.fillStyle = obj.fillStyle || result.fillStyle;
			result.fill = obj.fill || result.fill;
		}
		return result;
	};
	Material.standard = Material.create({name:'Default', stroke:true, lineWidth:1});
});